import time

from selenium.webdriver.common.by import By

from Base.page_base import PageBase


class PageAdd(PageBase):
    def __init__(self, driver):
        super().__init__(driver)
        self.driver = driver
        #选择商品
        self.__goods = (By.ID,'com.tpshop.malls:id/product_pic_img')
        #点击加入购物车
        self.__add_cart = (By.ID,'com.tpshop.malls:id/add_cart_tv')
        #点击确定
        self.__ok = (By.ID,'com.tpshop.malls:id/confirm_tv')
        #点击购物车
        self.__cart = (By.ID,'com.tpshop.malls:id/bottom_cart_img')
        ##添加购物车成功结果
        self.__add_cart_success = (By.ID,'com.tpshop.malls:id/product_name_tv')


    def add_goods(self):
        self.base_click(self.__goods)
        self.base_click(self.__add_cart)
        self.base_click(self.__ok)
        self.base_click(self.__cart)
    def get_add_cart_success(self):
        time.sleep(5)
        result = self.fd_element(self.__add_cart_success)
        return result.text


